from email.mime import base
import pstats
import xlrd
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support.expected_conditions import presence_of_element_located
import pyautogui as pi
import time
url_address = '/member/login/executeLogin.htm'
url_uat = 'http://61.187.51.25:8084'
url_dev = 'http://61.187.51.25:8800'
url_prod = 'https://www.holdcg.com'
url_local = 'http://localhost:6850'
PHONE = "18971592077"
class Setting:
    def __init__(self):
        filepath = './create_project_settings.xls'
        workbook =  xlrd.open_workbook(filepath)
        worksheet1 = workbook.sheet_by_name('sheet1')
        self.worksheet = worksheet1
    def getAccount(self):
        return str(self.worksheet.cell(1,0))[6:-1]  
    def getName(self):
        return str(self.worksheet.cell(1,1))[6:-1]
    def getUrl(self):
        return str(self.worksheet.cell(1,2))[6:-1]
    def getID(self):
        return str(self.worksheet.cell(1,3))[7:-2]
    def getBudget(self):
        return str(self.worksheet.cell(1,4))[7:-2]
    def getCustomurl(self):
        url_custom = str(self.worksheet.cell(2,2))[6:-1]
        return "http://"+url_custom

settings = Setting()
account1 = settings.getAccount()
budget1 = settings.getBudget()
customurl1 = settings.getCustomurl()
id1 = settings.getID()
name1 = settings.getName()
url1 = settings.getUrl()
class Url:
    def __init__(self,type):
        self.type = type
        self.end = '/member/login/executeLogin.htm'

    def getCompletUrl(self):
        if self.type == 'dev' or self.type == 'DEV':
            return url_dev + url_address
        elif self.type == 'uat' or self.type == 'UAT':
            return url_uat + url_address
        elif self.type == 'local' or self.type == 'LOCAL':
            return url_local + url_address
        elif self.type == 'prod' or self.type == 'PROD':
            return url_prod + url_address
        elif self.type == 'custom' or self.type == 'CUSTOM':
            return customurl1 + url_address
    def getUrl(self):
        url = self.begin+self.end;
        return url
    
    
class Person:
    password = 's#f]A4@_a;M,d-c[lPn)'
    
    def __init__(self, name, account, amount):
        self.name = name1
        self.account = account1
        self.amount = budget1
    
    def isDaili(self):
        begin_str = self.account[0:2]
        if begin_str == 'xz':
            return True
    
    def get_account(self):
        return self.account
    
    def get_name(self):
        return self.name
    
    def get_amount(self):
        return self.amount


def getperson():
    settings = Setting()
    name = settings.getName()
    account = settings.getAccount()
    amount = settings.getBudget()
    return Person(name, account, amount)

def getprojecttype(driver, person,id):
    if id == '11':
        zhaobiao(driver, person)
    elif id == '12':
        jingzhengxingtanpan(driver, person)
    elif id == '13':
        xunjiacaigou(driver, person)
    elif id == '14':
        jingzhengxingcuoshang(driver, person)
    elif id == '15':
        gongyingshangruwei(driver, person)
    elif id == '21':
        danyilaiyuan(driver, person)
    elif id == '22':
        jingjia(driver, person)
    elif id == '23':
        tanpancaigou(driver, person)
    elif id == '24':
        xunjiacaigou_noCA(driver, person)
    elif id == '25':
        gongyingshangruwei_noCA(driver, person)
    elif id == '26':
        add_yijia(driver, person)
    else:
        pi.alert('建项ID有误')


def getprojecttype_test(driver, person,id):
    if id == '11':
        p_type = 'CA企业招标'
        test(driver, person,p_type)
    elif id == '12':
        jingzhengxingtanpan(driver, person)
    elif id == '13':
        xunjiacaigou(driver, person)
    elif id == '14':
        jingzhengxingcuoshang(driver, person)
    elif id == '15':
        gongyingshangruwei(driver, person)
    elif id == '21':
        danyilaiyuan(driver, person)
    elif id == '22':
        jingjia(driver, person)
    elif id == '23':
        tanpancaigou(driver, person)
    elif id == '24':
        xunjiacaigou_noCA(driver, person)
    elif id == '25':
        gongyingshangruwei_noCA(driver, person)
    elif id == '26':
        add_yijia(driver, person)
    else:
        pi.alert('建项ID有误')


def pmlogin(driver, person, url):
    print(url)
    driver.get(url)
    locationLogin = (By.LINK_TEXT, '立即登录')
    try:
        WebDriverWait(driver, 20, 0, 5).until(presence_of_element_located(locationLogin))
    except:
        print('登录界面加载失败----')
    user_account = person.get_account()
    driver.find_element(By.ID, 'username').send_keys(user_account)
    driver.find_element(By.ID, 'xstr').send_keys(person.password)
    driver.find_element(By.LINK_TEXT, '立即登录').click()

def go2myproject(driver):
    driver.find_element(By.LINK_TEXT, '采购').click()
    driver.find_element(By.LINK_TEXT, '我的项目').click()
    x1="//span[@title='进行中的项目']"
    driver.find_element(By.XPATH,x1).click()
    # 添加项目
    x1="//button[@data-toggle='dropdown']"
    driver.find_element(By.XPATH,x1).click()

def getTimeStrip():
    time1 = time.strftime('%m月%d日%H:%M')
    return time1

def add_zhaobiao(driver, person):
    css1 = '.addBtn'
    driver.find_element(By.CSS_SELECTOR, css1).click()
    driver.find_element(By.LINK_TEXT, '网上开评标（需CA）').click()
    css2 = '#home1 > .zb'
    driver.find_element(By.CSS_SELECTOR, css2).click()
    time1 = getTimeStrip()
    time.sleep(5)
    driver.find_element(By.ID, 'bidName').send_keys('Test-企业招标(ca)' + time1)
    driver.find_element(By.CSS_SELECTOR, '.clearfix:nth-child(4) > .right').click()
    driver.find_element(By.LINK_TEXT, '不限').click()
    driver.find_element(By.CSS_SELECTOR, '.strip:nth-child(5) .col-xs-12:nth-child(1) .filter-option').click()
    driver.find_element(By.LINK_TEXT, '货物').click()
    driver.find_element(By.CSS_SELECTOR, '.col-xs-12:nth-child(2) .noCheck .filter-option').click()
    driver.find_element(By.LINK_TEXT, '材料').click()
    driver.find_element(By.CSS_SELECTOR, '.strip:nth-child(12) .col-xs-12:nth-child(1) .filter-option').click()
    driver.find_element(By.LINK_TEXT, '北京市').click()
    driver.find_element(By.ID, 'requireDepartName').send_keys('需求部门名称1:')
    driver.find_element(By.ID, 'requireLinkName').send_keys('需求部门联系人1', person.get_name())
    driver.find_element(By.ID, 'requireLinkTel').send_keys('13800138000')
    driver.find_element(By.ID, 'remark').send_keys('企业招标建项备注')
    driver.find_element(By.ID, 'totalInvestment').send_keys(person.get_amount())
    driver.find_element(By.ID, 'budgetAmount').send_keys(person.get_amount())
    driver.find_element(By.CSS_SELECTOR, '.strip:nth-child(1) div:nth-child(2) > .cb-wrap').click()

def add_zhaobiao_daili(driver, person):
    css1 = '.addBtn'
    driver.find_element(By.CSS_SELECTOR, css1).click()
    driver.find_element(By.LINK_TEXT, '网上开评标（需CA）').click()
    #css2 = '#home1 > .zb'
    #driver.find_element(By.CSS_SELECTOR, css2).click()
    xpath1 = "//*[@id='home1']/button[1]"
    driver.find_element(By.XPATH,xpath1).click()
    time1 = getTimeStrip()
    driver.find_element(By.ID, 'bidName').send_keys('Test-企业招标(ca)' + time1)
    driver.find_element(By.CSS_SELECTOR, '.clearfix:nth-child(4) > .right').click()
    driver.find_element(By.LINK_TEXT, '不限').click()
    driver.find_element(By.CSS_SELECTOR, '.strip:nth-child(5) .col-xs-12:nth-child(1) .filter-option').click()
    driver.find_element(By.LINK_TEXT, '货物').click()
    driver.find_element(By.CSS_SELECTOR, '.col-xs-12:nth-child(2) .noCheck .filter-option').click()
    driver.find_element(By.LINK_TEXT, '材料').click()
    kj_xpath = "//span[@id='selectConsignContract'][@class='btn btn-default']"
    driver.find_element(By.XPATH, kj_xpath).click()
    time.sleep(3)
    wt_xpath = "//input[@class='form-control'][@placeholder='委托合同名称']"
    driver.find_element(By.XPATH, wt_xpath).send_keys('test')
    cx_xpath = "//button[@id='modalDialogSearchBtn']"
    driver.find_element(By.XPATH, cx_xpath).click()
    input_1_xpath = "//input[@name='modalDialogId'][@id='modalDialogId0']"
    time.sleep(1)
    driver.find_element(By.XPATH, input_1_xpath).click()
    xz_xpath = "//button[@class='btn btn-primary '][@id='modalDialogSelect']"
    driver.find_element(By.XPATH, xz_xpath).click()
    dl_xpath = "//button[@class='btn dropdown-toggle bs-placeholder btn-default']"
    driver.find_element(By.XPATH, dl_xpath).click()
    driver.find_element(By.LINK_TEXT, '招标人').click()
    xm_xpath = "//*[@id='form']/div[1]/div[2]/div[13]/div[2]/div/div[1]/div/div/button"
    driver.find_element(By.XPATH, xm_xpath).click()
    driver.find_element(By.LINK_TEXT, '北京市').click()
    driver.find_element(By.ID, 'requireDepartName').send_keys('需求部门名称1')
    driver.find_element(By.ID, 'requireLinkName').send_keys('需求部门联系人1', person.get_name())
    driver.find_element(By.ID, 'requireLinkTel').send_keys('13800138000')
    driver.find_element(By.ID, 'exampelid3').click()
    time.sleep(2)
    driver.find_element(By.XPATH, "//td[@class='today active start-date active end-date available']").click()
    zbr_xpath = "//span[@id='selectTenderee']/i"
    driver.find_element(By.XPATH, zbr_xpath).click()
    time.sleep(3)
    srzbr_xpath = "//*[@id='modalDialogFrm']/div[2]/div[1]/div/input[2]"
    driver.find_element(By.XPATH, srzbr_xpath).send_keys('湖南大学')
    cx_xpath = "//button[@id='modalDialogSearchBtn']/span"
    driver.find_element(By.XPATH, cx_xpath).click()
    time.sleep(2)
    cx_xpath = "//input[@name='modalDialogId'][@id='modalDialogId0']"
    driver.find_element(By.XPATH, cx_xpath).click()
    cx_xpath = "//button[@id='modalDialogSelect']"
    driver.find_element(By.XPATH, cx_xpath).click()
    driver.find_element(By.ID, 'remark').send_keys('湘咨 - 企业招标建项备注')
    driver.find_element(By.ID, 'totalInvestment').send_keys(person.get_amount())
    driver.find_element(By.ID, 'budgetAmount').send_keys(person.get_amount())
    driver.find_element(By.ID, 'bidForm20').click()


def zhaobiao(driver, person):
    if person.isDaili():
        add_zhaobiao_daili(driver, person)
    else:
        add_zhaobiao(driver, person)


def add_jingzhengxingtanpan_daili(driver, person):
    css1 = '.addBtn'
    driver.find_element(By.CSS_SELECTOR, css1).click()
    driver.find_element(By.LINK_TEXT, '网上开评标（需CA）').click()
    css2 = '#home1 > .jzxtp'
    driver.find_element(By.CSS_SELECTOR, css2).click()
    time1 = getTimeStrip()
    driver.find_element(By.ID, 'bidName').send_keys('Test-竞争性谈判(ca)-' + time1)
    driver.find_element(By.CSS_SELECTOR, '.clearfix:nth-child(4) > .right').click()
    driver.find_element(By.LINK_TEXT, '不限').click()
    driver.find_element(By.CSS_SELECTOR, '.strip:nth-child(5) .col-xs-12:nth-child(1) .filter-option').click()
    driver.find_element(By.LINK_TEXT, '货物').click()
    driver.find_element(By.CSS_SELECTOR, '.col-xs-12:nth-child(2) .noCheck .filter-option').click()
    driver.find_element(By.LINK_TEXT, '材料').click()
    t_xpath = "//*[@id='selectConsignContract']/i"
    driver.find_element(By.XPATH, t_xpath).click()
    time.sleep(2)
    driver.find_element(By.NAME, 'bidContr.contractName').send_keys('test')
    time.sleep(1)
    t_xpath = "//*[@id='modalDialogSearchBtn']"
    driver.find_element(By.XPATH, t_xpath).click()
    time.sleep(2)
    driver.find_element(By.ID, 'modalDialogId0').click()
    driver.find_element(By.ID, 'modalDialogSelect').click()
    driver.find_element(By.CSS_SELECTOR, '.strip:nth-child(10) .col-xs-12:nth-child(1) .filter-option').click()
    driver.find_element(By.LINK_TEXT, '北京市').click()
    driver.find_element(By.ID, 'requireDepartName').send_keys('需求部门名称1')
    driver.find_element(By.ID, 'requireLinkName').send_keys('需求部门联系人1' + person.get_name())
    driver.find_element(By.ID, 'requireLinkTel').send_keys('13800138000')
    driver.find_element(By.ID, 'exampelid3').click()
    time.sleep(2)
    driver.find_element(By.XPATH, "//td[@class='today active start-date active end-date available']").click()
    driver.find_element(By.NAME, 'v(remark@String)').send_keys('建项备注:竞争性谈判_ca_xz')
    driver.find_element(By.ID, 'totalInvestment').send_keys(person.get_amount())
    driver.find_element(By.ID, 'budgetAmount').send_keys(person.get_amount())
    dw_xpath = "//*[@id='selectTenderee']/i"
    driver.find_element(By.XPATH, dw_xpath).click()
    in_name = 'Purchase.tendereeName'
    time.sleep(3)
    driver.find_element(By.NAME, in_name).send_keys('湖南大学')
    dw_xpath = "//*[@id='modalDialogSearchBtn']/span"
    driver.find_element(By.XPATH, dw_xpath).click()
    time.sleep(3)
    dw_xpath = "//*[@id='modalDialogId0']"
    driver.find_element(By.XPATH, dw_xpath).click()
    dw_xpath = "//*[@id='modalDialogSelect']"
    driver.find_element(By.XPATH, dw_xpath).click()
    
    try:
        dw_xpath = "//*[@id='popup_cancel']/span"
    finally:
        pass
    print('element not found')
    driver.find_element(By.ID, 'bidForms2020').click()
    return None



def add_jingzhengxingtanpan(driver, person):
    css1 = '.addBtn'
    driver.find_element(By.CSS_SELECTOR, css1).click()
    driver.find_element(By.LINK_TEXT, '网上开评标（需CA）').click()
    css2 = '#home1 > .jzxtp'
    driver.find_element(By.CSS_SELECTOR, css2).click()
    time1 = getTimeStrip()
    driver.find_element(By.ID, 'bidName').send_keys('Test-竞争性谈判(ca)-' + time1)
    driver.find_element(By.CSS_SELECTOR, '.clearfix:nth-child(4) > .right').click()
    driver.find_element(By.LINK_TEXT, '不限').click()
    driver.find_element(By.CSS_SELECTOR, '.strip:nth-child(5) .col-xs-12:nth-child(1) .filter-option').click()
    driver.find_element(By.LINK_TEXT, '货物').click()
    driver.find_element(By.CSS_SELECTOR, '.col-xs-12:nth-child(2) .noCheck .filter-option').click()
    driver.find_element(By.LINK_TEXT, '材料').click()
    driver.find_element(By.CSS_SELECTOR, '.strip:nth-child(10) .col-xs-12:nth-child(1) .filter-option').click()
    driver.find_element(By.LINK_TEXT, '北京市').click()
    driver.find_element(By.ID, 'requireDepartName').send_keys('需求部门名称1')
    driver.find_element(By.ID, 'requireLinkName').send_keys('需求部门联系人1' + person.get_name())
    driver.find_element(By.ID, 'requireLinkTel').send_keys('13800138000')
    driver.find_element(By.NAME, 'v(remark@String)').send_keys('建项备注:竞争性谈判_ca')
    driver.find_element(By.ID, 'totalInvestment').send_keys(person.get_amount())
    driver.find_element(By.ID, 'budgetAmount').send_keys(person.get_amount())
    driver.find_element(By.ID, 'bidForms2020').click()


def jingzhengxingtanpan(driver, person):
    if person.isDaili():
        add_jingzhengxingtanpan_daili(driver, person)
    else:
        add_jingzhengxingtanpan(driver, person)


def add_xunjiacaigou(driver, person):
    css1 = '.addBtn'
    driver.find_element(By.CSS_SELECTOR, css1).click()
    driver.find_element(By.LINK_TEXT, '网上开评标（需CA）').click()
    css2 = '#home1 > button.btn.btn-default.xjcg'
    driver.find_element(By.CSS_SELECTOR, css2).click()
    time1 = getTimeStrip()
    driver.find_element(By.ID, 'bidName').send_keys('Test-询价采购ca-' + time1)
    driver.find_element(By.CSS_SELECTOR, '.clearfix:nth-child(4) > .right').click()
    driver.find_element(By.LINK_TEXT, '不限').click()
    driver.find_element(By.CSS_SELECTOR, '.strip:nth-child(5) .col-xs-12:nth-child(1) .filter-option').click()
    driver.find_element(By.LINK_TEXT, '货物').click()
    driver.find_element(By.CSS_SELECTOR, '.col-xs-12:nth-child(2) .noCheck .filter-option').click()
    driver.find_element(By.LINK_TEXT, '材料').click()
    driver.find_element(By.CSS_SELECTOR, '.strip:nth-child(10) .col-xs-12:nth-child(1) .filter-option').click()
    driver.find_element(By.LINK_TEXT, '北京市').click()
    driver.find_element(By.ID, 'isSubmitEarnest20').click()
    driver.find_element(By.ID, 'requireDepartName').send_keys('需求部门名称1')
    driver.find_element(By.ID, 'requireLinkName').send_keys('需求部门联系人1' + person.get_name())
    driver.find_element(By.ID, 'requireLinkTel').send_keys('13800138000')
    driver.find_element(By.NAME, 'v(remark@String)').send_keys('建项备注:询价采购 ca')
    driver.find_element(By.ID, 'totalInvestment').send_keys(person.get_amount())
    driver.find_element(By.ID, 'budgetAmount').send_keys(person.get_amount())
    driver.find_element(By.ID, 'bidForms4020').click()


def add_xunjiacaigou_daili(driver, person):
    css1 = '.addBtn'
    driver.find_element(By.CSS_SELECTOR, css1).click()
    driver.find_element(By.LINK_TEXT, '网上开评标（需CA）').click()
    css2 = '#home1 > .xjcg'
    driver.find_element(By.CSS_SELECTOR, css2).click()
    time1 = getTimeStrip()
    driver.find_element(By.ID, 'bidName').send_keys('Test-询价采购ca-' + time1)
    driver.find_element(By.CSS_SELECTOR, '.clearfix:nth-child(4) > .right').click()
    driver.find_element(By.LINK_TEXT, '不限').click()
    driver.find_element(By.CSS_SELECTOR, '.strip:nth-child(5) .col-xs-12:nth-child(1) .filter-option').click()
    driver.find_element(By.LINK_TEXT, '货物').click()
    driver.find_element(By.CSS_SELECTOR, '.col-xs-12:nth-child(2) .noCheck .filter-option').click()
    driver.find_element(By.LINK_TEXT, '材料').click()
    t_xpath = "//*[@id='selectConsignContract']/i"
    driver.find_element(By.XPATH, t_xpath).click()
    time.sleep(3)
    driver.find_element(By.NAME, 'bidContr.contractName').send_keys('test')
    t_xpath = "//*[@id='modalDialogSearchBtn']"
    driver.find_element(By.XPATH, t_xpath).click()
    time.sleep(2)
    driver.find_element(By.ID, 'modalDialogId0').click()
    driver.find_element(By.ID, 'modalDialogSelect').click()
    driver.find_element(By.CSS_SELECTOR, '.strip:nth-child(10) .col-xs-12:nth-child(1) .filter-option').click()
    driver.find_element(By.LINK_TEXT, '北京市').click()
    driver.find_element(By.ID, 'requireDepartName').send_keys('需求部门名称1')
    driver.find_element(By.ID, 'requireLinkName').send_keys('需求部门联系人1' + person.get_name())
    driver.find_element(By.ID, 'requireLinkTel').send_keys('13800138000')
    driver.find_element(By.ID, 'exampelid3').click()
    time.sleep(2)
    driver.find_element(By.XPATH, "//td[@class='today active start-date active end-date available']").click()
    driver.find_element(By.NAME, 'v(remark@String)').send_keys('建项备注:询价采购 ca xz')
    driver.find_element(By.ID, 'totalInvestment').send_keys(person.get_amount())
    driver.find_element(By.ID, 'budgetAmount').send_keys(person.get_amount())
    dw_xpath = "//*[@id='selectTenderee']/i"
    driver.find_element(By.XPATH, dw_xpath).click()
    xj_name = "//*[@id='modalDialogFrm']/div[2]/div[1]/div/input[2]"
    time.sleep(2)
    driver.find_element(By.XPATH, xj_name).send_keys('湖南大学')
    dw_xpath = "//*[@id='modalDialogSearchBtn']/span"
    driver.find_element(By.XPATH, dw_xpath).click()
    time.sleep(3)
    dw_xpath = "//*[@id='modalDialogId0']"
    driver.find_element(By.XPATH, dw_xpath).click()
    dw_xpath = "//*[@id='modalDialogSelect']"
    driver.find_element(By.XPATH, dw_xpath).click()
    
    try:
        dw_xpath = "//*[@id='popup_cancel']/span"
    finally:
        pass
    print('element not found')
    driver.find_element(By.ID, 'bidForms4020').click()
    return None



def xunjiacaigou(driver, person):
    if person.isDaili():
        add_xunjiacaigou_daili(driver, person)
    else:
        add_xunjiacaigou(driver, person)


def add_jingzhengxingcuoshang(driver, person):
    css1 = '.addBtn'
    driver.find_element(By.CSS_SELECTOR, css1).click()
    driver.find_element(By.LINK_TEXT, '网上开评标（需CA）').click()
    css2 = '#home1 > button.btn.btn-default.jzxcs'
    driver.find_element(By.CSS_SELECTOR, css2).click()
    time1 = getTimeStrip()
    driver.find_element(By.ID, 'bidName').send_keys('Test-竞争性磋商(ca)-' + time1)
    driver.find_element(By.CSS_SELECTOR, '.clearfix:nth-child(4) > .right').click()
    driver.find_element(By.LINK_TEXT, '不限').click()
    driver.find_element(By.CSS_SELECTOR, '.strip:nth-child(5) .col-xs-12:nth-child(1) .filter-option').click()
    driver.find_element(By.LINK_TEXT, '货物').click()
    driver.find_element(By.CSS_SELECTOR, '.col-xs-12:nth-child(2) .noCheck .filter-option').click()
    driver.find_element(By.LINK_TEXT, '材料').click()
    driver.find_element(By.CSS_SELECTOR, '.strip:nth-child(10) .col-xs-12:nth-child(1) .filter-option').click()
    driver.find_element(By.LINK_TEXT, '北京市').click()
    driver.find_element(By.ID, 'requireDepartName').send_keys('需求部门名称1')
    driver.find_element(By.ID, 'requireLinkName').send_keys('需求部门联系人1' + person.get_name())
    driver.find_element(By.ID, 'requireLinkTel').send_keys('13800138000')
    driver.find_element(By.NAME, 'v(remark@String)').send_keys('建项备注:竞争性磋商 ca')
    driver.find_element(By.ID, 'totalInvestment').send_keys(person.get_amount())
    driver.find_element(By.ID, 'budgetAmount').send_keys(person.get_amount())
    driver.find_element(By.ID, 'bidForms9020').click()


def add_jingzhengxingcuoshang_daili(driver, person):
    css1 = '.addBtn'
    driver.find_element(By.CSS_SELECTOR, css1).click()
    driver.find_element(By.LINK_TEXT, '网上开评标（需CA）').click()
    css2 = '#home1 > button.btn.btn-default.jzxcs'
    driver.find_element(By.CSS_SELECTOR, css2).click()
    time1 = getTimeStrip()
    driver.find_element(By.ID, 'bidName').send_keys('Test-竞争性磋商(CA)-' + time1)
    driver.find_element(By.CSS_SELECTOR, '.clearfix:nth-child(4) > .right').click()
    driver.find_element(By.LINK_TEXT, '不限').click()
    driver.find_element(By.CSS_SELECTOR, '.strip:nth-child(5) .col-xs-12:nth-child(1) .filter-option').click()
    driver.find_element(By.LINK_TEXT, '货物').click()
    driver.find_element(By.CSS_SELECTOR, '.col-xs-12:nth-child(2) .noCheck .filter-option').click()
    driver.find_element(By.LINK_TEXT, '材料').click()
    driver.find_element(By.XPATH, "//*[@id='selectConsignContract']/i").click()
    time.sleep(2)
    driver.find_element(By.NAME, 'bidContr.contractName').send_keys('test')
    driver.find_element(By.XPATH, "//*[@id='modalDialogSearchBtn']/span").click()
    time.sleep(3)
    driver.find_element(By.XPATH, "//*[@id='modalDialogId0']").click()
    driver.find_element(By.XPATH, "//*[@id='modalDialogSelect']/span").click()
    driver.find_element(By.CSS_SELECTOR, '.strip:nth-child(10) .col-xs-12:nth-child(1) .filter-option').click()
    driver.find_element(By.LINK_TEXT, '北京市').click()
    driver.find_element(By.ID, 'requireDepartName').send_keys('需求部门名称1')
    driver.find_element(By.ID, 'requireLinkName').send_keys('需求部门联系人1' + person.get_name())
    driver.find_element(By.ID, 'requireLinkTel').send_keys('13800138000')
    driver.find_element(By.ID, 'exampelid3').click()
    time.sleep(2)
    driver.find_element(By.XPATH, "//td[@class='today active start-date active end-date available']").click()
    driver.find_element(By.NAME, 'v(remark@String)').send_keys('建项备注:竞争性磋商 xz ca')
    driver.find_element(By.ID, 'totalInvestment').send_keys(person.get_amount())
    driver.find_element(By.ID, 'budgetAmount').send_keys(person.get_amount())
    dw_xpath = "//*[@id='selectTenderee']/i"
    driver.find_element(By.XPATH, dw_xpath).click()
    time.sleep(2)
    in_name = 'Purchase.tendereeName'
    driver.find_element(By.NAME, in_name).send_keys('湖南大学')
    dw_xpath = "//*[@id='modalDialogSearchBtn']/span"
    driver.find_element(By.XPATH, dw_xpath).click()
    time.sleep(3)
    dw_xpath = "//*[@id='modalDialogId0']"
    driver.find_element(By.XPATH, dw_xpath).click()
    dw_xpath = "//*[@id='modalDialogSelect']"
    driver.find_element(By.XPATH, dw_xpath).click()
    
    try:
        dw_xpath = "//*[@id='popup_cancel']/span"
    finally:
        pass
    print('element not found')
    driver.find_element(By.ID, 'bidForms9020').click()
    return None



def jingzhengxingcuoshang(driver, person):
    if person.isDaili():
        add_jingzhengxingcuoshang_daili(driver, person)
    else:
        add_jingzhengxingcuoshang(driver, person)


def add_gongyingshangruwei_daili(driver, person):
    css1 = '.addBtn'
    driver.find_element(By.CSS_SELECTOR, css1).click()
    driver.find_element(By.LINK_TEXT, '网上开评标（需CA）').click()
    css2 = '#home1 > .gysrw'
    driver.find_element(By.CSS_SELECTOR, css2).click()
    time1 = getTimeStrip()
    driver.find_element(By.ID, 'bidName').send_keys('Test-供应商入围（CA)-' + time1)
    driver.find_element(By.CSS_SELECTOR, '.clearfix:nth-child(4) > .right').click()
    driver.find_element(By.LINK_TEXT, '不限').click()
    driver.find_element(By.CSS_SELECTOR, '.strip:nth-child(5) .col-xs-12:nth-child(1) .filter-option').click()
    driver.find_element(By.LINK_TEXT, '货物').click()
    driver.find_element(By.CSS_SELECTOR, '.col-xs-12:nth-child(2) .noCheck .filter-option').click()
    driver.find_element(By.LINK_TEXT, '材料').click()
    t_xpath = "//*[@id='selectConsignContract']/i"
    driver.find_element(By.XPATH, t_xpath).click()
    time.sleep(2)
    driver.find_element(By.NAME, 'bidContr.contractName').send_keys('test')
    t_xpath = "//*[@id='modalDialogSearchBtn']"
    driver.find_element(By.XPATH, t_xpath).click()
    time.sleep(2)
    driver.find_element(By.ID, 'modalDialogId0').click()
    driver.find_element(By.ID, 'modalDialogSelect').click()
    driver.find_element(By.XPATH, "//button[@data-toggle='dropdown'][@data-id='projectareaProvince']").click()
    driver.find_element(By.LINK_TEXT, '北京市').click()
    driver.find_element(By.ID, 'requireDepartName').send_keys('需求部门名称1')
    driver.find_element(By.ID, 'requireLinkName').send_keys('需求部门联系人1' + person.get_name())
    driver.find_element(By.ID, 'requireLinkTel').send_keys('13800138000')
    driver.find_element(By.ID, 'exampelid3').click()
    time.sleep(2)
    driver.find_element(By.XPATH, "//td[@class='today active start-date active end-date available']").click()
    driver.find_element(By.NAME, 'v(remark@String)').send_keys('建项备注:供应商入围（CA）xz')
    dw_xpath = "//*[@id='selectTenderee']/i"
    driver.find_element(By.XPATH, dw_xpath).click()
    time.sleep(3)
    in_name = 'libTenderees.tendereeName'
    driver.find_element(By.NAME, in_name).send_keys('湖南大学')
    dw_xpath = "//*[@id='modalDialogSearchBtn']/span"
    driver.find_element(By.XPATH, dw_xpath).click()
    time.sleep(3)
    dw_xpath = "//*[@id='modalDialogId0']"
    driver.find_element(By.XPATH, dw_xpath).click()
    dw_xpath = "//*[@id='modalDialogSelect']"
    driver.find_element(By.XPATH, dw_xpath).click()
    
    try:
        dw_xpath = "//*[@id='popup_cancel']/span"
    finally:
        pass
    print('element not found')
    driver.find_element(By.ID, 'totalInvestment').send_keys(person.get_amount())
    driver.find_element(By.ID, 'budgetAmount').send_keys(person.get_amount())
    return None



def add_gongyingshangruwei(driver, person):
    css1 = '.addBtn'
    driver.find_element(By.CSS_SELECTOR, css1).click()
    driver.find_element(By.LINK_TEXT, '网上开评标（需CA）').click()
    css2 = '#home1 > .gysrw'
    driver.find_element(By.CSS_SELECTOR, css2).click()
    time1 = getTimeStrip()
    driver.find_element(By.ID, 'bidName').send_keys('Test-供应商入围（CA)-' + time1)
    driver.find_element(By.CSS_SELECTOR, '.clearfix:nth-child(4) > .right').click()
    driver.find_element(By.LINK_TEXT, '不限').click()
    driver.find_element(By.CSS_SELECTOR, '.strip:nth-child(5) .col-xs-12:nth-child(1) .filter-option').click()
    driver.find_element(By.LINK_TEXT, '货物').click()
    driver.find_element(By.CSS_SELECTOR, '.col-xs-12:nth-child(2) .noCheck .filter-option').click()
    driver.find_element(By.LINK_TEXT, '材料').click()
    driver.find_element(By.XPATH, "//button[@data-toggle='dropdown'][@data-id='projectareaProvince']").click()
    driver.find_element(By.LINK_TEXT, '北京市').click()
    driver.find_element(By.ID, 'requireDepartName').send_keys('需求部门名称1')
    driver.find_element(By.ID, 'requireLinkName').send_keys('需求部门联系人1' + person.get_name())
    driver.find_element(By.ID, 'requireLinkTel').send_keys('13800138000')
    driver.find_element(By.NAME, 'v(remark@String)').send_keys('建项备注:供应商入围（CA）')
    driver.find_element(By.ID, 'totalInvestment').send_keys(person.get_amount())
    driver.find_element(By.ID, 'budgetAmount').send_keys(person.get_amount())


def gongyingshangruwei(driver, person):
    if person.isDaili():
        add_gongyingshangruwei_daili(driver, person)
    else:
        add_gongyingshangruwei(driver, person)


def add_danyilaiyuan(driver, person):
    css1 = '.addBtn'
    driver.find_element(By.CSS_SELECTOR, css1).click()
    driver.find_element(By.LINK_TEXT, '网上开评标（无需CA）').click()
    css2 = '#profile1 > .dylycg'
    driver.find_element(By.CSS_SELECTOR, css2).click()
    time1 = getTimeStrip()
    driver.find_element(By.ID, 'bidName').send_keys('Test-单一来源采购无ca-' + time1)
    driver.find_element(By.CSS_SELECTOR, '.strip:nth-child(4) .col-xs-12:nth-child(1) .pull-left').click()
    driver.find_element(By.LINK_TEXT, '货物').click()
    driver.find_element(By.CSS_SELECTOR, '.strip:nth-child(4) .col-xs-12:nth-child(2) .pull-left').click()
    driver.find_element(By.LINK_TEXT, '材料').click()
    driver.find_element(By.CSS_SELECTOR, '.strip:nth-child(6) .filter-option').click()
    driver.find_element(By.LINK_TEXT, '不限').click()
    driver.find_element(By.CSS_SELECTOR, '.strip:nth-child(7) .col-xs-12:nth-child(1) .pull-left').click()
    driver.find_element(By.LINK_TEXT, '北京市').click()
    driver.find_element(By.ID, 'requireDepartName').send_keys('需求部门名称1')
    driver.find_element(By.ID, 'requireLinkName').send_keys('需求部门联系人1')
    driver.find_element(By.ID, 'requireLinkTel').send_keys('13800138000')
    driver.find_element(By.NAME, 'v(remark@String)').send_keys('建项备注:单一来源采购（无CA）')
    driver.find_element(By.ID, 'totalInvestment').send_keys(person.get_amount())
    driver.find_element(By.ID, 'budgetAmount').send_keys(person.get_amount())
    driver.find_element(By.ID, 'tenderOfferMode2').click()
    css_3 = '.percents > .btn'
    driver.find_element(By.CSS_SELECTOR, css_3).click()
    driver.find_element(By.LINK_TEXT, '3').click()


def add_danyilaiyuan_daili(driver, person):
    css1 = '.addBtn'
    driver.find_element(By.CSS_SELECTOR, css1).click()
    driver.find_element(By.LINK_TEXT, '网上开评标（无需CA）').click()
    css2 = '#profile1 > .dylycg'
    driver.find_element(By.CSS_SELECTOR, css2).click()
    time1 = getTimeStrip()
    driver.find_element(By.ID, 'bidName').send_keys('Test-单一来源采购无ca-' + time1)
    driver.find_element(By.CSS_SELECTOR, '.strip:nth-child(4) .col-xs-12:nth-child(1) .pull-left').click()
    driver.find_element(By.LINK_TEXT, '货物').click()
    driver.find_element(By.CSS_SELECTOR, '.strip:nth-child(4) .col-xs-12:nth-child(2) .pull-left').click()
    driver.find_element(By.LINK_TEXT, '材料').click()
    driver.find_element(By.CSS_SELECTOR, '.strip:nth-child(6) .filter-option').click()
    driver.find_element(By.LINK_TEXT, '不限').click()
    driver.find_element(By.CSS_SELECTOR, '.strip:nth-child(7) .col-xs-12:nth-child(1) .pull-left').click()
    driver.find_element(By.LINK_TEXT, '北京市').click()
    t_xpath = "//*[@id='selectConsignContract']/i"
    driver.find_element(By.XPATH, t_xpath).click()
    time.sleep(3)
    driver.find_element(By.NAME, 'bidContr.contractName').send_keys('test')
    t_xpath = "//*[@id='modalDialogSearchBtn']"
    driver.find_element(By.XPATH, t_xpath).click()
    time.sleep(2)
    driver.find_element(By.ID, 'modalDialogId0').click()
    driver.find_element(By.ID, 'modalDialogSelect').click()
    t_xpath = "//*[@id='selectTenderee']/i"
    driver.find_element(By.XPATH, t_xpath).click()
    time.sleep(3)
    driver.find_element(By.NAME, 'libTendereesCg.tendereeName').send_keys('湖南大学')
    driver.find_element(By.ID, 'modalDialogSearchBtn').click()
    time.sleep(3)
    driver.find_element(By.ID, 'modalDialogId0').click()
    driver.find_element(By.ID, 'modalDialogSelect').click()
    
    try:
        driver.find_element(By.ID, 'popup_cancel').click()
    finally:
        pass
    print('element not found')
    driver.find_element(By.ID, 'exampelid3').click()
    time.sleep(2)
    driver.find_element(By.XPATH, "//td[@class='today active start-date active end-date available']").click()
    driver.find_element(By.ID, 'requireDepartName').send_keys('需求部门名称1')
    driver.find_element(By.ID, 'requireLinkName').send_keys('需求部门联系人1')
    driver.find_element(By.ID, 'requireLinkTel').send_keys('13800138000')
    driver.find_element(By.NAME, 'v(remark@String)').send_keys('建项备注:单一来源采购（无CA）xz')
    driver.find_element(By.ID, 'totalInvestment').send_keys(person.get_amount())
    driver.find_element(By.ID, 'budgetAmount').send_keys(person.get_amount())
    driver.find_element(By.ID, 'tenderOfferMode2').click()
    css_3 = '.percents > .btn'
    driver.find_element(By.CSS_SELECTOR, css_3).click()
    driver.find_element(By.LINK_TEXT, '3').click()
    return None



def danyilaiyuan(driver, person):
    if person.isDaili():
        add_danyilaiyuan_daili(driver, person)
    else:
        add_danyilaiyuan(driver, person)


def add_jingjia(driver, person):
    css1 = '.addBtn'
    driver.find_element(By.CSS_SELECTOR, css1).click()
    driver.find_element(By.LINK_TEXT, '网上开评标（无需CA）').click()
    css2 = '#profile1 > .jj'
    driver.find_element(By.CSS_SELECTOR, css2).click()
    time1 = getTimeStrip()
    driver.find_element(By.ID, 'bidName').send_keys('Test-竞价无ca-' + time1)
    driver.find_element(By.CSS_SELECTOR, '.strip:nth-child(4) .col-xs-12:nth-child(1) .pull-left').click()
    driver.find_element(By.LINK_TEXT, '货物').click()
    driver.find_element(By.CSS_SELECTOR, '.strip:nth-child(4) .col-xs-12:nth-child(2) .pull-left').click()
    driver.find_element(By.LINK_TEXT, '材料').click()
    driver.find_element(By.XPATH,"""//*[@id="saveFrm"]/div[2]/div[2]/div[7]/div[2]/div/div/div/div/button""").click()
    driver.find_element(By.LINK_TEXT, '不限').click()
    driver.find_element(By.XPATH,"""//*[@id="saveFrm"]/div[2]/div[2]/div[13]/div[2]/div/div[1]/div/div/button""").click()
    driver.find_element(By.LINK_TEXT, '北京市').click()
    driver.find_element(By.ID, 'requireDepartName').send_keys('需求部门名称1')
    driver.find_element(By.ID, 'requireLinkName').send_keys('需求部门联系人1' + person.get_name())
    driver.find_element(By.ID, 'requireLinkTel').send_keys('13800138000')
    driver.find_element(By.NAME, 'v(remark@String)').send_keys('建项备注:网上竞价（无CA）')
    driver.find_element(By.ID, 'totalInvestment').send_keys(person.get_amount())
    driver.find_element(By.ID, 'budgetAmount').send_keys(person.get_amount())
    driver.find_element(By.ID, 'bidForm20').click()
    driver.find_element(By.ID, 'gradientPrice').send_keys('400')


def add_jingjia_daili(driver, person):
    css1 = '.addBtn'
    driver.find_element(By.CSS_SELECTOR, css1).click()
    driver.find_element(By.LINK_TEXT, '网上开评标（无需CA）').click()
    css2 = '#profile1 > .jj'
    driver.find_element(By.CSS_SELECTOR, css2).click()
    time1 = getTimeStrip()
    driver.find_element(By.ID, 'bidName').send_keys('Test-竞价无ca-' + time1)
    driver.find_element(By.CSS_SELECTOR, '.strip:nth-child(4) .col-xs-12:nth-child(1) .pull-left').click()
    driver.find_element(By.LINK_TEXT, '货物').click()
    driver.find_element(By.CSS_SELECTOR, '.strip:nth-child(4) .col-xs-12:nth-child(2) .pull-left').click()
    driver.find_element(By.LINK_TEXT, '材料').click()
    driver.find_element(By.XPATH,"""//*[@id="saveFrm"]/div[2]/div[2]/div[7]/div[2]/div/div/div/div/button""").click()
    driver.find_element(By.LINK_TEXT, '不限').click()
    driver.find_element(By.XPATH,"""//*[@id="saveFrm"]/div[2]/div[2]/div[13]/div[2]/div/div[1]/div/div/button""").click()
    driver.find_element(By.LINK_TEXT, '北京市').click()
    t_xpath = "//*[@id='selectConsignContract']/i"
    driver.find_element(By.XPATH, t_xpath).click()
    time.sleep(3)
    driver.find_element(By.NAME, 'bidContr.contractName').send_keys('test')
    t_xpath = "//*[@id='modalDialogSearchBtn']"
    driver.find_element(By.XPATH, t_xpath).click()
    time.sleep(2)
    driver.find_element(By.ID, 'modalDialogId0').click()
    driver.find_element(By.ID, 'modalDialogSelect').click()
    t_xpath = "//*[@id='selectTenderee']/i"
    driver.find_element(By.XPATH, t_xpath).click()
    time.sleep(3)
    driver.find_element(By.NAME, 'libTendereesCg.tendereeName').send_keys('湖南大学')
    driver.find_element(By.ID, 'modalDialogSearchBtn').click()
    time.sleep(2)
    driver.find_element(By.ID, 'modalDialogId0').click()
    driver.find_element(By.ID, 'modalDialogSelect').click()
    
    try:
        driver.find_element(By.ID, 'popup_cancel').click()
    finally:
        pass
    print('element not found')
    driver.find_element(By.ID, 'requireDepartName').send_keys('需求部门名称1')
    driver.find_element(By.ID, 'requireLinkName').send_keys('需求部门联系人1', person.get_name())
    driver.find_element(By.ID, 'requireLinkTel').send_keys('13800138000')
    driver.find_element(By.ID, 'exampelid3').click()
    time.sleep(2)
    driver.find_element(By.XPATH, "//td[@class='today active start-date active end-date available']").click()
    driver.find_element(By.NAME, 'v(remark@String)').send_keys('建项备注:网上竞价（无CA）xz')
    driver.find_element(By.ID, 'totalInvestment').send_keys(person.get_amount())
    driver.find_element(By.ID, 'budgetAmount').send_keys(person.get_amount())
    driver.find_element(By.ID, 'bidForm20').click()
    driver.find_element(By.ID, 'gradientPrice').send_keys('400')
    return None



def jingjia(driver, person):
    if person.isDaili():
        add_jingjia_daili(driver, person)
    else:
        add_jingjia(driver, person)


def add_tanpancaigou(driver, person):
    css1 = '.addBtn'
    driver.find_element(By.CSS_SELECTOR, css1).click()
    driver.find_element(By.LINK_TEXT, '网上开评标（无需CA）').click()
    css2 = '#profile1 > .jzxtpxm3'
    driver.find_element(By.CSS_SELECTOR, css2).click()
    time1 = getTimeStrip()
    driver.find_element(By.ID, 'bidName').send_keys('Test-谈判采购项目无ca-' + time1)
    driver.find_element(By.CSS_SELECTOR, '.strip:nth-child(4) .col-xs-12:nth-child(1) .pull-left').click()
    driver.find_element(By.LINK_TEXT, '货物').click()
    driver.find_element(By.CSS_SELECTOR, '.strip:nth-child(4) .col-xs-12:nth-child(2) .pull-left').click()
    driver.find_element(By.LINK_TEXT, '材料').click()
    driver.find_element(By.CSS_SELECTOR, '.strip:nth-child(6) .filter-option').click()
    driver.find_elemnet(By.CLASS_NAME,"btn dropdown-toggle bs-placeholder btn-default").click()
    #driver.find_element(By.XPATH,"""//*[@id="saveFrm"]/div[1]/div[2]/div[7]/div[2]/div/div/div/div/button""").click()
    driver.find_element(By.LINK_TEXT, '不限').click()
    #driver.find_element(By.CSS_SELECTOR, '.strip:nth-child(7) .col-xs-12:nth-child(1) .pull-left').click()
    driver.find_element(By.XPATH,"""//*[@id="saveFrm"]/div[1]/div[2]/div[13]/div[2]/div/div[1]/div/div/button""").click()
    driver.find_element(By.LINK_TEXT, '北京市').click()
    driver.find_element(By.ID, 'requireDepartName').send_keys('需求部门名称1')
    driver.find_element(By.ID, 'requireLinkName').send_keys('需求部门联系人1' + person.get_name())
    driver.find_element(By.ID, 'requireLinkTel').send_keys('13800138000')
    driver.find_element(By.NAME, 'v(remark@String)').send_keys('建项备注:谈判采购项目（无CA）')
    driver.find_element(By.ID, 'totalInvestment').send_keys(person.get_amount())
    driver.find_element(By.ID, 'budgetAmount').send_keys(person.get_amount())
    driver.find_element(By.ID, 'bidForm20').click()
    css3 = '#saveFrm > div.model-block.overflow > div.model-block-content.clearfix > div.strip.taxType > div.right.right-col > div > div.taxName.input-group > div > div > div > button > span.filter-option.pull-left'
    driver.find_element(By.CSS_SELECTOR, css3).click()
    driver.find_element(By.LINK_TEXT, '3').click()


def add_tanpancaigou_daili(driver, person):
    css1 = '.addBtn'
    driver.find_element(By.CSS_SELECTOR, css1).click()
    driver.find_element(By.LINK_TEXT, '网上开评标（无需CA）').click()
    css2 = '#profile1 > .jzxtpxm3'
    driver.find_element(By.CSS_SELECTOR, css2).click()
    time1 = getTimeStrip()
    driver.find_element(By.ID, 'bidName').send_keys('Test-谈判采购项目无ca-' + time1)
    driver.find_element(By.CSS_SELECTOR, '.strip:nth-child(4) .col-xs-12:nth-child(1) .pull-left').click()
    driver.find_element(By.LINK_TEXT, '货物').click()
    driver.find_element(By.CSS_SELECTOR, '.strip:nth-child(4) .col-xs-12:nth-child(2) .pull-left').click()
    driver.find_element(By.LINK_TEXT, '材料').click()
    driver.find_element(By.CSS_SELECTOR, '.strip:nth-child(6) .filter-option').click()
    driver.find_element(By.LINK_TEXT, '不限').click()
    driver.find_element(By.CSS_SELECTOR, '.strip:nth-child(7) .col-xs-12:nth-child(1) .pull-left').click()
    driver.find_element(By.LINK_TEXT, '北京市').click()
    kj_xpath = "//span[@id='selectConsignContract'][@class='btn btn-default']"
    driver.find_element(By.XPATH, kj_xpath).click()
    time.sleep(3)
    wt_xpath = "//input[@class='form-control'][@placeholder='委托合同名称']"
    driver.find_element(By.XPATH, wt_xpath).send_keys('test')
    cs1 = '#modalDialogSearchBtn > span'
    driver.find_element(By.CSS_SELECTOR, cs1).click()
    time.sleep(1)
    input_1_xpath = "//input[@name='modalDialogId'][@id='modalDialogId0']"
    driver.find_element(By.XPATH, input_1_xpath).click()
    xz_xpath = "//button[@class='btn btn-primary '][@id='modalDialogSelect']"
    driver.find_element(By.XPATH, xz_xpath).click()
    t_xpath = "//*[@id='selectTenderee']/i"
    driver.find_element(By.XPATH, t_xpath).click()
    time.sleep(3)
    driver.find_element(By.XPATH, "//*[@id='modalDialogFrm']/div[2]/div[1]/div/input[2]").send_keys('湖南大学')
    driver.find_element(By.ID, 'modalDialogSearchBtn').click()
    time.sleep(2)
    driver.find_element(By.ID, 'modalDialogId0').click()
    driver.find_element(By.ID, 'modalDialogSelect').click()
    
    try:
        driver.find_element(By.ID, 'popup_cancel').click()
    finally:
        pass
    print('element not found')
    driver.find_element(By.ID, 'requireDepartName').send_keys('需求部门名称1')
    driver.find_element(By.ID, 'requireLinkName').send_keys('需求部门联系人1', person.get_name())
    driver.find_element(By.ID, 'requireLinkTel').send_keys('13800138000')
    driver.find_element(By.ID, 'exampelid3').click()
    time.sleep(2)
    driver.find_element(By.XPATH, "//td[@class='today active start-date active end-date available']").click()
    driver.find_element(By.NAME, 'v(remark@String)').send_keys('建项备注:谈判采购项目（无CA）')
    driver.find_element(By.ID, 'totalInvestment').send_keys(person.get_amount())
    driver.find_element(By.ID, 'budgetAmount').send_keys(person.get_amount())
    driver.find_element(By.ID, 'bidForm20').click()
    css3 = '#saveFrm > div.model-block.overflow > div.model-block-content.clearfix > div.strip.taxType > div.right.right-col > div > div.taxName.input-group > div > div > div > button > span.filter-option.pull-left'
    driver.find_element(By.CSS_SELECTOR, css3).click()
    t_xpath = '/html/body/div[5]/div[6]/div/ul/li[2]/a'
    driver.find_element(By.XPATH, t_xpath).click()
    return None



def tanpancaigou(driver, person):
    if person.isDaili():
        add_tanpancaigou_daili(driver, person)
    else:
        add_tanpancaigou(driver, person)


def add_xunjiacaigou_noca(driver, person):
    css1 = '.addBtn'
    driver.find_element(By.CSS_SELECTOR, css1).click()
    driver.find_element(By.LINK_TEXT, '网上开评标（无需CA）').click()
    css2 = '#profile1 > .xbjxm3'
    driver.find_element(By.CSS_SELECTOR, css2).click()
    time1 = getTimeStrip()
    driver.find_element(By.ID, 'bidName').send_keys('Test-询价采购无ca-' + time1)
    driver.find_element(By.CSS_SELECTOR, '.strip:nth-child(4) .col-xs-12:nth-child(1) .pull-left').click()
    driver.find_element(By.LINK_TEXT, '货物').click()
    driver.find_element(By.CSS_SELECTOR, '.strip:nth-child(4) .col-xs-12:nth-child(2) .pull-left').click()
    driver.find_element(By.LINK_TEXT, '材料').click()
    driver.find_element(By.CSS_SELECTOR, '.strip:nth-child(6) .filter-option').click()
    driver.find_element(By.LINK_TEXT, '不限').click()
    driver.find_element(By.CSS_SELECTOR, '.strip:nth-child(7) .col-xs-12:nth-child(1) .pull-left').click()
    driver.find_element(By.LINK_TEXT, '北京市').click()
    driver.find_element(By.ID, 'requireDepartName').send_keys('需求部门名称1')
    driver.find_element(By.ID, 'requireLinkName').send_keys('需求部门联系人1' + person.get_name())
    driver.find_element(By.ID, 'requireLinkTel').send_keys('13800138000')
    driver.find_element(By.NAME, 'v(remark@String)').send_keys('建项备注:询价采购（无CA）')
    driver.find_element(By.ID, 'totalInvestment').send_keys(person.get_amount())
    driver.find_element(By.ID, 'budgetAmount').send_keys(person.get_amount())
    driver.find_element(By.ID, 'bidForm20').click()
    css3 = '#saveFrm > div.model-block.overflow > div.model-block-content.clearfix > div.strip.taxType > div.right.right-col > div > div.taxName.input-group > div > div > div > button > span.filter-option.pull-left'
    driver.find_element(By.CSS_SELECTOR, css3).click()
    driver.find_element(By.LINK_TEXT, '3').click()


def add_xunjiacaigou_noca_daili(driver, person):
    css1 = '.addBtn'
    driver.find_element(By.CSS_SELECTOR, css1).click()
    driver.find_element(By.LINK_TEXT, '网上开评标（无需CA）').click()
    css2 = '#profile1 > .xbjxm3'
    driver.find_element(By.CSS_SELECTOR, css2).click()
    time1 = getTimeStrip()
    driver.find_element(By.ID, 'bidName').send_keys('Test-询价采购无ca-' + time1)
    driver.find_element(By.CSS_SELECTOR, '.strip:nth-child(4) .col-xs-12:nth-child(1) .pull-left').click()
    driver.find_element(By.LINK_TEXT, '货物').click()
    driver.find_element(By.CSS_SELECTOR, '.strip:nth-child(4) .col-xs-12:nth-child(2) .pull-left').click()
    driver.find_element(By.LINK_TEXT, '材料').click()
    driver.find_element(By.CSS_SELECTOR, '.strip:nth-child(6) .filter-option').click()
    driver.find_element(By.LINK_TEXT, '不限').click()
    driver.find_element(By.CSS_SELECTOR, '.strip:nth-child(7) .col-xs-12:nth-child(1) .pull-left').click()
    driver.find_element(By.LINK_TEXT, '北京市').click()
    kj_xpath = "//span[@id='selectConsignContract'][@class='btn btn-default']"
    driver.find_element(By.XPATH, kj_xpath).click()
    time.sleep(3)
    wt_xpath = "//input[@class='form-control'][@placeholder='委托合同名称']"
    driver.find_element(By.XPATH, wt_xpath).send_keys('test')
    cx_xpath = "//button[@id='modalDialogSearchBtn']"
    driver.find_element(By.XPATH, cx_xpath).click()
    time.sleep(2)
    input_1_xpath = "//input[@name='modalDialogId'][@id='modalDialogId0']"
    driver.find_element(By.XPATH, input_1_xpath).click()
    xz_xpath = "//button[@class='btn btn-primary '][@id='modalDialogSelect']"
    driver.find_element(By.XPATH, xz_xpath).click()
    t_xpath = "//*[@id='selectTenderee']/i"
    driver.find_element(By.XPATH, t_xpath).click()
    time.sleep(3)
    driver.find_element(By.XPATH, "//*[@id='modalDialogFrm']/div[2]/div[1]/div/input[2]").send_keys('湖南大学')
    driver.find_element(By.ID, 'modalDialogSearchBtn').click()
    driver.find_element(By.ID, 'modalDialogId0').click()
    driver.find_element(By.ID, 'modalDialogSelect').click()
    
    try:
        driver.find_element(By.ID, 'popup_cancel').click()
    finally:
        pass
    print('element not found')
    driver.find_element(By.ID, 'requireDepartName').send_keys('需求部门名称1')
    driver.find_element(By.ID, 'requireLinkName').send_keys('需求部门联系人1' + person.get_name())
    driver.find_element(By.ID, 'requireLinkTel').send_keys('13800138000')
    driver.find_element(By.ID, 'exampelid3').click()
    time.sleep(2)
    driver.find_element(By.XPATH, "//td[@class='today active start-date active end-date available']").click()
    driver.find_element(By.NAME, 'v(remark@String)').send_keys('建项备注:询价采购（无CA）')
    driver.find_element(By.ID, 'totalInvestment').send_keys(person.get_amount())
    driver.find_element(By.ID, 'budgetAmount').send_keys(person.get_amount())
    driver.find_element(By.ID, 'bidForm20').click()
    css3 = '#saveFrm > div.model-block.overflow > div.model-block-content.clearfix > div.strip.taxType > div.right.right-col > div > div.taxName.input-group > div > div > div > button > span.filter-option.pull-left'
    driver.find_element(By.CSS_SELECTOR, css3).click()
    driver.find_element(By.LINK_TEXT, '3').click()
    return None



def xunjiacaigou_noCA(driver, person):
    if person.isDaili():
        add_xunjiacaigou_noca_daili(driver, person)
    else:
        add_xunjiacaigou_noca(driver, person)


def add_gongyingshangruwei_noca(driver, person):
    css1 = '.addBtn'
    driver.find_element(By.CSS_SELECTOR, css1).click()
    driver.find_element(By.LINK_TEXT, '网上开评标（无需CA）').click()
    css2 = '#profile1 > .gysrw'
    driver.find_element(By.CSS_SELECTOR, css2).click()
    time1 = getTimeStrip()
    driver.find_element(By.ID, 'bidName').send_keys('Test-供应商入围无ca-' + time1)
    driver.find_element(By.XPATH, "//button[@data-toggle='dropdown'][@data-id='industryCategory']").click()
    driver.find_element(By.LINK_TEXT, '不限').click()
    driver.find_element(By.CSS_SELECTOR, '.strip:nth-child(5) .col-xs-12:nth-child(1) .pull-left').click()
    driver.find_element(By.LINK_TEXT, '货物').click()
    driver.find_element(By.CSS_SELECTOR, '.strip:nth-child(5) .col-xs-12:nth-child(2) .pull-left').click()
    driver.find_element(By.LINK_TEXT, '材料').click()
    driver.find_element(By.CSS_SELECTOR, '.strip:nth-child(12) .col-xs-12:nth-child(1) .pull-left').click()
    driver.find_element(By.LINK_TEXT, '北京市').click()
    driver.find_element(By.ID, 'requireDepartName').send_keys('需求部门名称1')
    driver.find_element(By.ID, 'requireLinkName').send_keys('需求部门联系人1' + person.get_name())
    driver.find_element(By.ID, 'requireLinkTel').send_keys('13800138000')
    driver.find_element(By.NAME, 'v(remark@String)').send_keys('建项备注:供应商入围（无CA）')
    driver.find_element(By.ID, 'totalInvestment').send_keys(person.get_amount())
    driver.find_element(By.ID, 'budgetAmount').send_keys(person.get_amount())


def add_gongyingshangruwei_noca_daili(driver, person):
    css1 = '.addBtn'
    driver.find_element(By.CSS_SELECTOR, css1).click()
    driver.find_element(By.LINK_TEXT, '网上开评标（无需CA）').click()
    css2 = '#profile1 > .gysrw'
    driver.find_element(By.CSS_SELECTOR, '#profile1 > button.btn.btn-default.gysrw').click()
    time1 = getTimeStrip()
    driver.find_element(By.ID, 'bidName').send_keys('Test-供应商入围无ca-' + time1)
    driver.find_element(By.XPATH, "//button[@data-toggle='dropdown'][@data-id='industryCategory']").click()
    driver.find_element(By.LINK_TEXT, '不限').click()
    driver.find_element(By.CSS_SELECTOR, '.strip:nth-child(5) .col-xs-12:nth-child(1) .pull-left').click()
    driver.find_element(By.LINK_TEXT, '货物').click()
    driver.find_element(By.CSS_SELECTOR, '.strip:nth-child(5) .col-xs-12:nth-child(2) .pull-left').click()
    driver.find_element(By.LINK_TEXT, '材料').click()
    kj_xpath = "//span[@id='selectConsignContract'][@class='btn btn-default']"
    driver.find_element(By.XPATH, kj_xpath).click()
    time.sleep(3)
    wt_xpath = "//input[@class='form-control'][@placeholder='委托合同名称']"
    driver.find_element(By.XPATH, wt_xpath).send_keys('test')
    driver.find_element(By.ID, 'modalDialogId0').click()
    driver.find_element(By.ID, 'modalDialogSelect').click()
    wt_xpath = "//*[@id='form']/div[1]/div[2]/div[10]/div[2]/div/div/div/button"
    driver.find_element(By.XPATH, wt_xpath).click()
    time.sleep(2)
    driver.find_element(By.LINK_TEXT, '中标人').click()
    driver.find_element(By.XPATH, "//*[@id='form']/div[1]/div[2]/div[13]/div[2]/div/div[1]/div/div/button/span[1]").click()
    driver.find_element(By.LINK_TEXT, '北京市').click()
    driver.find_element(By.ID, 'requireDepartName').send_keys('需求部门名称1')
    driver.find_element(By.ID, 'requireLinkName').send_keys('需求部门联系人1' + person.get_name())
    driver.find_element(By.ID, 'requireLinkTel').send_keys('13800138000')
    driver.find_element(By.ID, 'exampelid3').click()
    t_xpath = '/html/body/div[5]/div/div[1]/div[2]/table/tbody/tr[2]/td[3]'
    driver.find_element(By.XPATH, t_xpath).click()
    t_xpath = "//*[@id='selectTenderee']/i"
    driver.find_element(By.XPATH, t_xpath).click()
    time.sleep(3)
    driver.find_element(By.NAME, 'libTenderees.tendereeName').send_keys('湖南大学')
    driver.find_element(By.ID, 'modalDialogSearchBtn').click()
    time.sleep(2)
    driver.find_element(By.ID, 'modalDialogId0').click()
    driver.find_element(By.ID, 'modalDialogSelect').click()
    
    try:
        driver.find_element(By.ID, 'popup_cancel').click()
    finally:
        pass
    print('element not found')
    driver.find_element(By.NAME, 'v(remark@String)').send_keys('建项备注:供应商入围（无CA）xz')
    driver.find_element(By.ID, 'totalInvestment').send_keys(person.get_amount())
    driver.find_element(By.ID, 'budgetAmount').send_keys(person.get_amount())
    return None



def gongyingshangruwei_noCA(driver, person):
    if person.isDaili():
        add_gongyingshangruwei_noca_daili(driver, person)
    else:
        add_gongyingshangruwei_noca(driver, person)


def add_yijia(driver, person):
    css1 = '.addBtn'
    driver.find_element(By.CSS_SELECTOR, css1).click()
    driver.find_element(By.LINK_TEXT, '网上开评标（无需CA）').click()
    css2 = '#profile1 > .yj'
    driver.find_element(By.CSS_SELECTOR, css2).click()
    time1 = getTimeStrip()
    driver.find_element(By.ID, 'bidName').send_keys('Test-议价无ca-' + time1)
    css3 = '#selectLinkName > i'
    driver.find_element(By.CSS_SELECTOR, css3).click()
    time.sleep(2)
    driver.find_element(By.XPATH, "//input[@class='form-control'][@name='feeBailTran.linkMan']").send_keys(person.get_name())
    driver.find_element(By.XPATH, "//button[@id='modalDialogSearchBtn']").click()
    time.sleep(1)
    driver.find_element(By.XPATH, "//input[@type='radio'][@id='modalDialogId0'][@value='radio']").click()
    driver.find_element(By.XPATH, "//button[@type='button'][@id='modalDialogSelect']").click()
    driver.find_element(By.ID, 'budgetAmount').send_keys(person.get_amount())
    driver.find_element(By.CSS_SELECTOR, '#saveFrm > div.model-block.overflow > div.strip.taxType.taxName.input-group > div.right.right-col > div > div > div > div > div > button').click()
    driver.find_element(By.LINK_TEXT, '3').click()

def dali_info(driver):
    x1 = """//span[@id="selectConsignContract"]"""
    driver.find_element(By.XPATH,x1).click()
    time.sleep(3)
    x1 = """//input[@placeholder="委托合同名称"]"""
    driver.find_element(By.XPATH,x1).send_keys("test")
    x1 = """//button[@id="modalDialogSearchBtn"]"""
    driver.find_element(By.XPATH,x1).click()
    time.sleep(3)
    x1 = """//input[@id="modalDialogId0"]"""
    driver.find_element(By.XPATH,x1).click()
    x1 = """//button[@id="modalDialogSelect"]"""
    driver.find_element(By.XPATH,x1).click()
    # 代理服务收取对象
    x1 = """//button[@data-id="serviceReceiveObject"]"""
    driver.find_element(By.XPATH,x1).click()
    driver.find_element(By.LINK_TEXT,"中标人").click()
    x1 = """//button[@data-id="serviceFeeMode"]"""
    driver.find_element(By.XPATH,x1).click()
    driver.find_element(By.LINK_TEXT,"固定金额").click()
    x1 = """//input[@name="exampelid3"]"""
    driver.find_element(By.XPATH,x1).click()
    time.sleep(2)
    x1 = """//td[@class="today active start-date active end-date available"]"""
    driver.find_element(By.XPATH,x1).click()
    #招标人
    x1 = """//span[@id="selectTenderee"]"""
    driver.find_element(By.XPATH,x1).click()
    time.sleep(2)
    x1 = """//input[@placeholder="招标人名称"]"""
    driver.find_element(By.XPATH,x1).send_keys("湖南大学")
    #x1 = """//*[@id="modalDialogSearchBtn"]"""
    #driver.find_element(By.XPATH,x1).click()
    x1 = """//button[@class="btn btn-primary btn-flat searchBtn"]/span"""
    driver.find_element(By.XPATH,x1).click()
    time.sleep(2)
    x1 = """//input[@id="modalDialogId0"]"""
    driver.find_element(By.XPATH,x1).click()
    x1  = """//button[@id="modalDialogSelect"]"""
    driver.find_element(By.XPATH,x1).click()
def base_info(driver,user,p_type):
    # 项目名称
    x1 = """//input[@class="form-control unNameBlanks required"]"""
    #driver.find_element(By.XPATH,x1).send_keys("Test-"+p_type+"-"+getTimeStrip())
    driver.find_element(By.XPATH,x1).send_keys("Test-"+p_type)
    # 行业类别
    x1 = """//button[@data-id="industryCategory"]"""
    driver.find_element(By.XPATH,x1).click()
    driver.find_element(By.LINK_TEXT,"不限").click()
    # 项目分类
    x1 = """//button[@data-id="bidTypeSelect"]"""
    driver.find_element(By.XPATH,x1).click()
    driver.find_element(By.LINK_TEXT,"货物").click()
    x1 = """//button[@data-id="bidTypeSecondSelect"]"""
    driver.find_element(By.XPATH,x1).click()
    driver.find_element(By.LINK_TEXT,"材料").click()
    # 项目所属地区
    x1="""//button[@data-id="projectareaProvince"]"""
    driver.find_element(By.XPATH,x1).click()
    x1="""//li[@data-original-index="18"]"""
    driver.find_element(By.XPATH,x1).click()
    # 需求部门
    x1 = """//input[@name="v(requireDepartName@String)"]"""
    driver.find_element(By.XPATH,x1).send_keys('需求部门')
    x1 = """//input[@name="v(requireLinkName@String)"]"""
    driver.find_element(By.XPATH,x1).send_keys(user.get_name())
    x1 = """//input[@placeholder="请输入需求部门联系方式"]"""
    driver.find_element(By.XPATH,x1).send_keys(PHONE)
    # 备注 投资 金额
    x1 = """//textarea[@id="remark"]"""
    driver.find_element(By.XPATH,x1).send_keys("备注:"+user.get_name()+p_type)
    x1 = """//input[@id="totalInvestment"]"""
    driver.find_element(By.XPATH,x1).send_keys(user.get_amount())
    x1 = """//input[@id="budgetAmount"]"""
    driver.find_element(By.XPATH,x1).send_keys(user.get_amount())
    if(user.isDaili()):
        dali_info(driver)
# test
def test(driver,user,p_type):
    # CA项目
    driver.find_element(By.LINK_TEXT,"网上开评标（需CA）").click()
    # 招标项目
    x1="//button[@class='btn btn-default zb']"
    driver.find_element(By.XPATH,x1).click()
    base_info(driver,user,p_type)
    
if __name__ == '__main__':
    """
    test
    """
    user = Person("何思乐","BG18573145270","120")
    url = "http://47.100.19.22/"
    options = webdriver.ChromeOptions()
    options.add_argument("--start-maximized")
    driver = webdriver.Chrome(options=options)
    pmlogin(driver,user,url)
    go2myproject(driver)
    #test(driver,user)
    getprojecttype_test(driver,user,"11")

    """
    user = Person(name1,account1,budget1)
    url = Url(url1).getCompletUrl()
    options = webdriver.ChromeOptions()
    options.add_argument('--args --disable-web-security')
    options.add_argument('--start-maximized')
    options.add_argument('--incognito')
    options.add_argument('--lang=zh-CN')
    options.add_argument('disable-infobars')
    options.add_experimental_option('useAutomationExtension', False)
    #options.add_experimental_option("excludeSwitches", ['enable-automation'])
    s = Service('D:\data\webdriver\chromedriver.exe')
    try:
        driver = webdriver.Chrome(s, options)
        #print('use the webdriver in d')
    except:
        print("Use the default path of webdriver.")
        #print('webdriver not found in this path')
    driver = webdriver.Chrome(options=options)
    pmlogin(driver, user, url)
    go2myproject(driver)
    getprojecttype(driver, user,id1)
    """